#include <iostream>
#include <string>


class Task
{
public:
    Task(int x = int(), int y = int (), char op = char())
        :_x(x)
        ,_y(y)
        ,_op(op)
        ,_exitCode(0)
    {}

    ~Task()
    {}

    void operator()()
    {
        switch(_op)
        {
            case '+':
                _result = _x + _y;
                break;
            case '-':
                _result = _x - _y;
                break;
            case '*':
                _result = _x * _y;
                break;
            case '/':
            {
                if(_y == 0)
                    _exitCode = -1;
                else
                    _result = _x / _y;
                break;
            }
            case '%':
            {
                if(_y == 0)
                    _exitCode = -2;
                else
                    _result = _x % _y;
                break;
            }
            default:
                cout << "_op error" << endl;
                break;
        }
    }

    //返回表达式
    std::string formatArg()
    {
        return (std::to_string(_x) + _op + std::to_string(_y) + "=");
    }

    //返回结果及错误码
    std::string formatRes()
    {
        return (std::to_string(_result) + "(" + std::to_string(_exitCode) + ")");
    }

private:
    int _x;
    int _y;
    char _op;
    int _result;
    int _exitCode;  //退出码
};